package com.nfit.service.impl.others;

import com.nfit.service.OthersService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OthersServiceImpl implements OthersService {

    @Autowired
    private RabbitTemplate rabbit;

    @Override
    public void sendMessage(String message) {
        rabbit.convertAndSend("broadcast_exchange","System", message);
        System.out.println("[x] Sent '" + message + "'");
    }

    @RabbitListener(queues = "#{@userQueue.name}",autoStartup = "true")
    @Override
    public String getMessage(String message) {
        return message;
    }
}